package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Goods;
import com.atguigu.jxc.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @description: 库存接口
 * @author:
 * @date: 2023/2/5 13:53
 * @version: v1.0
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;
    /**
     * @description: 分页查询商品的库存信息
     * @author
     * @date 2023/2/5 16:01
     */

    @PostMapping("/listInventory")
    public Map<String,Object> listInventory(Integer page, Integer rows, String codeOrName, Integer goodsTypeId){

        Map<String, Object> resultMap=goodsService.listInventory(page,rows,codeOrName,goodsTypeId);


        return resultMap;
    }

    /**
     * @description: 查询所有的商品信息
     * @author 化一帆
     * @date 2023/2/10 18:18
     */
    @RequestMapping("/list")
    public Map<String,Object> list (Integer page, Integer rows, String goodsName, Integer goodsTypeId){

        return goodsService.list(page,rows,goodsName,goodsTypeId);
    }


    /**
     * @description: 添加商品或者修改
     * http://localhost:8080/goods/save?goodsId=37
     * @author 化一帆
     * @date 2023/2/10 19:06
     */
    @PostMapping("/save")
    public ServiceVO save(Goods goods){
        return goodsService.save(goods);
    }

}
